package online.hxstart.code.concurrent.chapter04;

import java.util.HashMap;
import java.util.Map;

/**
 * @author huxing
 * @date 19-4-24 星期三 上午11:58
 * @describe
 */
public class HashMapDeadLock {
  private final Map<String, String> map = new HashMap<>();

  public void add(String key, String value) {
    this.map.put(key, value);
  }

  public static void main(String[] args) {
    final HashMapDeadLock hashMapDeadLock = new HashMapDeadLock();
    for (int i = 0; i < 2; i++) {
      new Thread(
              () -> {
                for (int j = 0; j < Integer.MAX_VALUE; j++) {
                  hashMapDeadLock.add(String.valueOf(j), String.valueOf(j));
                }
              })
          .start();
    }
  }
}
